package com.kgc.bigdata.spark.scala

class ConstrutorExtendsDemo {
}

class Person(val name: String, val age: Int) {
  println("Person constructor enter ~~~~~~")
  val school = "kgc"
  println("Person constructor leave ~~~~~~")
}

class Student(name: String, age: Int, var major: String) extends Person(name, age) {
  println("Student constructor enter ~~~~~~")
  println("Student constructor leave ~~~~~~")
}


object ConstrutorExtendsDemo extends App {
  //调用主构造器
  var person = new Person("zhangsan", 21)
  println("name is:" + person.name + " , age is: " + person.age + " , school is: " + person.school)

  //初始化子类对象
  var student = new Student("wangwu", 15, "Math")
  println("name is:" + student.name + " , age is: " + student.age + " , major is: " + student.major + " , school is: " + student.school)
  println(student);

}

